package y_2025.m03.d21.t01;

public class Triangle {
    private double a, b, c;

    public Triangle(double a, double b, double c) {
        validateSides(a, b, c);
        this.a = a;
        this.b = b;
        this.c = c;
    }

    private static void validateSides(double a, double b, double c) {
        boolean isPositive = (a > 0) && (b > 0) && (c > 0);
        boolean isTriangle = (a + b > c) && (a + c > b) && (b + c > a);

        if (!isPositive) {
            System.out.println("边长必须大于0");
        }
        if (!isTriangle) {
            System.out.println("三边无法构成三角形: " + a + ", " + b + ", " + c);
        }
    }

    public double getPerimeter() {
        return a + b + c;
    }
}